// 子系统：电视
class TV {
  turnOn() {
    return "电视已开启";
  }
  turnOff() {
    return "电视已关闭";
  }
  setChannel(channel: number) {
    return `切换到频道 ${channel}`;
  }
  setVolume(volume: number) {
    return `音量设置为 ${volume}`;
  }
}

// 子系统：音响系统
class SoundSystem {
  turnOn() {
    return "音响系统已开启";
  }
  turnOff() {
    return "音响系统已关闭";
  }
  setVolume(volume: number) {
    return `音量设置为 ${volume}`;
  }
  setMode(mode: string) {
    return `音效模式设置为 ${mode}`;
  }
}

// 子系统：灯光系统
class LightingSystem {
  turnOn() {
    return "灯光已开启";
  }
  turnOff() {
    return "灯光已关闭";
  }
  setBrightness(brightness: number) {
    return `亮度设置为 ${brightness}%`;
  }
  setMode(mode: string) {
    return `灯光模式设置为 ${mode}`;
  }
}

// 外观类：家庭影院控制器
class HomeTheaterFacade {
  private tv: TV;
  private soundSystem: SoundSystem;
  private lighting: LightingSystem;

  constructor() {
    this.tv = new TV();
    this.soundSystem = new SoundSystem();
    this.lighting = new LightingSystem();
  }

  // 一键开启电影模式
  watchMovie() {
    const actions = [
      this.lighting.turnOn(),
      this.lighting.setBrightness(30),
      this.lighting.setMode("电影模式"),
      this.tv.turnOn(),
      this.tv.setChannel(1),
      this.tv.setVolume(50),
      this.soundSystem.turnOn(),
      this.soundSystem.setVolume(60),
      this.soundSystem.setMode("环绕声")
    ];
    return actions;
  }

  // 一键关闭所有设备
  endMovie() {
    const actions = [
      this.tv.turnOff(),
      this.soundSystem.turnOff(),
      this.lighting.turnOff()
    ];
    return actions;
  }

  // 一键开启音乐模式
  listenToMusic() {
    const actions = [
      this.lighting.turnOn(),
      this.lighting.setBrightness(50),
      this.lighting.setMode("氛围模式"),
      this.soundSystem.turnOn(),
      this.soundSystem.setVolume(40),
      this.soundSystem.setMode("音乐模式")
    ];
    return actions;
  }
}

export { HomeTheaterFacade }; 